package com.uzai.console.mapper;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.uzai.console.entity.DeviceAuth;
import com.uzai.console.vo.deviceauth.DeviceAuthForWechantAndWxworkVo;
import org.apache.ibatis.annotations.Param;
import com.uzai.console.dto.device.deviceauth.DeviceAuthQuery;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;

@Repository
public interface DeviceAuthMapper {
    int deleteById(@Param("id") Long id);

    int insert(DeviceAuth record);

    int insertSelective(DeviceAuth record);

    DeviceAuth selectById(@Param("id") Long id);

    DeviceAuth selectByDeviceIdAndProductCode(@Param("deviceId") String deviceId, @Param("productCode") String productCode);

    DeviceAuth selectByDeviceIdAndProductCodeAndDeivceTypeId(@Param("deviceId") String deviceId, @Param("productCode") String productCode, @Param("deviceTypeId") Integer deviceTypeId);

    DeviceAuth selectEarliestAuthByDeviceId(@Param("deviceId") String deviceId);

    DeviceAuth selectLastAuthByDeviceId(@Param("deviceId") String deviceId);

    int updateByIdSelective(DeviceAuth record);

    int updateById(DeviceAuth record);

    /**
     * 分页查询
     * @param page
     * @param query
     * @return
     */
    ArrayList<DeviceAuth> findByList(Page<DeviceAuth> page, @Param("query") DeviceAuthQuery query);

    /**
     * 查询所有
     * @param query
     * @return
     */
    ArrayList<DeviceAuth> findByList(@Param("query") DeviceAuthQuery query);


    /**
     * 查询所有数量
     * @param query
     * @return
     */
    Integer findByCount(@Param("query") DeviceAuthQuery query);

    /**
     * 查询同一个设备id针对同一个产品出现2个授权的数据
     * @return
     */
    ArrayList<DeviceAuthForWechantAndWxworkVo> findByListForWechantAndWxwork();


    List<DeviceAuth> selectListByDeviceIdAndProductCode(@Param("deviceId") String deviceId, @Param("productCode") String productCode);

}